# DP: - When running the ACATS, look for the gnat tools in their new
# DP:   directory (build/gnattools), and for the shared libraries in
# DP:   build/gcc/ada/rts-shared-zcx, build/libgnatvsn and build/libgnatprj.

Index: b/src/gcc/testsuite/ada/acats/run_acats
===================================================================
--- a/src/gcc/testsuite/ada/acats/run_acats
+++ b/src/gcc/testsuite/ada/acats/run_acats
@@ -5,51 +5,28 @@
    exit 1
 fi
 
-# Set up environment to use the Ada compiler from the object tree
-
-host_gnatchop=`type gnatchop | awk '{print $3}'`
-host_gnatmake=`type gnatmake | awk '{print $3}'`
-ROOT=`${PWDCMD-pwd}`
-BASE=`cd $ROOT/../../..; ${PWDCMD-pwd}`
+echo '#!/bin/sh' > host_gnatchop
+echo exec /usr/bin/gnatchop '$*' >> host_gnatchop
 
-PATH=$BASE:$ROOT:$PATH
-ADA_INCLUDE_PATH=$BASE/ada/rts
-LD_LIBRARY_PATH=$ADA_INCLUDE_PATH:$BASE:$LD_LIBRARY_PATH
-ADA_OBJECTS_PATH=$ADA_INCLUDE_PATH
+chmod +x host_gnatchop
 
-if [ ! -d $ADA_INCLUDE_PATH ]; then
-   echo gnatlib missing, exiting.
-   exit 1
-fi
+echo '#!/bin/sh' > host_gnatmake
+echo echo '$PATH' '$*' >> host_gnatmake
+echo exec /usr/bin/gnatmake '$*' >> host_gnatmake
 
-if [ ! -f $BASE/gnatchop ]; then
-   echo gnattools missing, exiting.
-   exit 1
-fi
+chmod +x host_gnatmake
 
-if [ ! -f $BASE/gnatmake ]; then
-   echo gnattools missing, exiting.
-   exit 1
-fi
+# Set up environment to use the Ada compiler from the object tree
 
+ROOT=`${PWDCMD-pwd}`
+BASE=`cd $ROOT/../../..; ${PWDCMD-pwd}`
+PATH=$BASE:$ROOT:$PATH
+GNATTOOLS=`cd $BASE/../gnattools; ${PWDCMD-pwd}`
+LIBGNATVSN=`cd $BASE/../libgnatvsn; ${PWDCMD-pwd}`
+LIBGNATPRJ=`cd $BASE/../libgnatprj; ${PWDCMD-pwd}`
 GCC_DRIVER="$BASE/xgcc"
 GCC="$BASE/xgcc -B$BASE/"
 export PATH ADA_INCLUDE_PATH ADA_OBJECTS_PATH GCC_DRIVER GCC LD_LIBRARY_PATH
-
-echo '#!/bin/sh' > host_gnatchop
-echo PATH=`dirname $host_gnatchop`:'$PATH' >> host_gnatchop
-echo unset ADA_INCLUDE_PATH ADA_OBJECTS_PATH GCC_EXEC_PREFIX >> host_gnatchop
-echo export PATH >> host_gnatchop
-echo exec gnatchop '"$@"' >> host_gnatchop
-
-chmod +x host_gnatchop
-
-echo '#!/bin/sh' > host_gnatmake
-echo PATH=`dirname $host_gnatmake`:'$PATH' >> host_gnatmake
-echo unset ADA_INCLUDE_PATH ADA_OBJECTS_PATH GCC_EXEC_PREFIX >> host_gnatmake
-echo export PATH >> host_gnatmake
-echo exec gnatmake '"$@"' >> host_gnatmake
-
-chmod +x host_gnatmake
+export GNATTOOLS LIBGNATVSN LIBGNATPRJ
 
 exec $testdir/run_all.sh ${1+"$@"}
Index: b/src/gcc/testsuite/ada/acats/run_all.sh
===================================================================
--- a/src/gcc/testsuite/ada/acats/run_all.sh
+++ b/src/gcc/testsuite/ada/acats/run_all.sh
@@ -12,6 +12,10 @@
 gccflags="-O2"
 gnatflags="-gnatws"
 
+RTS=`cd $GNATTOOLS/../gcc/ada/rts-shared-zcx; ${PWDCMD-pwd}`
+LD_LIBRARY_PATH=$RTS:$LIBGNATVSN:$LIBGNATPRJ
+export LD_LIBRARY_PATH
+
 target_run () {
 $*
 }
@@ -48,15 +52,25 @@
 fi
 
 target_gnatchop () {
-  gnatchop --GCC="$GCC_DRIVER" $*
+  display ADA_INCLUDE_PATH=$GNATTOOLS/../../src/gcc/ada $GNATTOOLS/gnatchop --GCC="$GCC_DRIVER" $*
+  ADA_INCLUDE_PATH=$GNATTOOLS/../../src/gcc/ada $GNATTOOLS/gnatchop --GCC="$GCC_DRIVER" $*
 }
 
 target_gnatmake () {
-  echo gnatmake --GCC=\"$GCC\" $gnatflags $gccflags $* -largs $EXTERNAL_OBJECTS --GCC=\"$GCC\"
-  gnatmake --GCC="$GCC" $gnatflags $gccflags $* -largs $EXTERNAL_OBJECTS --GCC="$GCC"
+  RTS="$GNATTOOLS/../gcc/ada/rts-shared-zcx"
+  EXTERNAL_OBJECTS="$EXTERNAL_OBJECTS $RTS/adaint.o $RTS/sysdep.o $RTS/init.o"
+  display $GNATTOOLS/gnatmake -I- -I$RTS -I. \
+      --GCC=\"$GCC\" --GNATBIND="$GNATTOOLS/gnatbind" \
+      --GNATLINK="$GNATTOOLS/gnatlink" $gnatflags $gccflags $* \
+      -bargs -static -largs $EXTERNAL_OBJECTS --GCC=\"$GCC -I- -I$RTS -I.\"
+  $GNATTOOLS/gnatmake -I- -I$RTS -I. \
+      --GCC="$GCC" --GNATBIND="$GNATTOOLS/gnatbind" \
+      --GNATLINK="$GNATTOOLS/gnatlink" $gnatflags $gccflags $* \
+      -bargs -static -largs $EXTERNAL_OBJECTS --GCC="$GCC -I- -I$RTS -I."
 }
 
 target_gcc () {
+  display $GCC $gccflags $*
   $GCC $gccflags $*
 }
 
@@ -84,8 +98,8 @@
 display `$GCC -v 2>&1`
 display host=`gcc -dumpmachine`
 display target=$target
-display `type gnatmake`
-gnatls -v >> $dir/acats.log
+display `type $GNATTOOLS/gnatmake`
+$GNATTOOLS/gnatls -I- -I$RTS -v >> $dir/acats.log
 display ""
 
 display "		=== acats support ==="
Index: b/src/gcc/testsuite/lib/gnat.exp
===================================================================
--- a/src/gcc/testsuite/lib/gnat.exp
+++ b/src/gcc/testsuite/lib/gnat.exp
@@ -83,7 +83,6 @@
     global gluefile wrap_flags
     global gnat_initialized
     global GNAT_UNDER_TEST
-    global GNAT_UNDER_TEST_ORIG
     global TOOL_EXECUTABLE
     global gnat_libgcc_s_path
     global gnat_target_current
@@ -92,14 +91,7 @@
 
     if { $gnat_initialized == 1 } { return }
 
-    if ![info exists GNAT_UNDER_TEST] then {
-	if [info exists TOOL_EXECUTABLE] {
-	    set GNAT_UNDER_TEST "$TOOL_EXECUTABLE"
-	} else {
-	    set GNAT_UNDER_TEST "[local_find_gnatmake]"
-	}
-        set GNAT_UNDER_TEST_ORIG "$GNAT_UNDER_TEST"
-    }
+    set GNAT_UNDER_TEST "$rootme/../gnattools/gnatmake -I$rootme/ada/rts-shared-zcx --GCC=$rootme/xgcc --GNATBIND=$rootme/../gnattools/gnatbind --GNATLINK=$rootme/../gnattools/gnatlink -cargs -B$rootme -largs --GCC=$rootme/xgcc -B$rootme -margs"
 
     if ![info exists tmpdir] then {
 	set tmpdir /tmp
@@ -129,7 +121,6 @@
     global gluefile wrap_flags
     global srcdir
     global GNAT_UNDER_TEST
-    global GNAT_UNDER_TEST_ORIG
     global TOOL_OPTIONS
     global ld_library_path
     global gnat_libgcc_s_path
@@ -144,10 +135,10 @@
        } else {
            set gnat_rts_opt "--RTS=[get_multilibs]/libada"
        }
-        set GNAT_UNDER_TEST "$GNAT_UNDER_TEST_ORIG $gnat_rts_opt"
+       set GNAT_UNDER_TEST "$GNAT_UNDER_TEST $gnat_rts_opt"
     }
 
-    set ld_library_path ".:${gnat_libgcc_s_path}"
+    set ld_library_path ".:${gnat_libgcc_s_path}:${rootme}/ada/rts-shared-zcx:${rootme}/libgnatvsn:${rootme}/libgnatprj"
     lappend options "compiler=$GNAT_UNDER_TEST -q -f"
     lappend options "timeout=[timeout_value]"
 
